import java.util.Stack;

public class MinStack {
    //最小队列的模拟实现；
    public  Stack<Integer> stack;
    public  Stack<Integer> minStack;
    public MinStack(){
        stack=new Stack<>();
        minStack=new Stack<>();
    }
    //1.向最小队列中添加元素；
    public void pull(int val){
        stack.push(val);
        if(minStack.isEmpty()){
            minStack.push(val);
        }else{
            int peekVal=minStack.peek();
            if(val<peekVal){
                minStack.push(val);
            }
        }
    }
    //2.删除最小队列中的元素；
    public void  pop(){
      if(stack.isEmpty()){
          return;
      }
      int val=stack.peek();
      if(val==minStack.peek()){
          minStack.pop();
      }
    }
    //3.进行获取队列的最小值；
    public int peek(){
        if(stack.isEmpty()){
            return -1;
        }else{
            return minStack.peek();
        }
    }
    //4.进行最小栈的打印；
    public void disPlay(){
        while(minStack.isEmpty()){
            System.out.print(minStack.peek());
            minStack.pop();
        }
        System.out.println();
    }

}
